package com.demo.transaction.service;

import com.demo.transaction.annotation.MainTransaction;
import com.demo.transaction.domain.TestOne;
import com.demo.transaction.mapper.TestOneMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @Author: lkz
 * @Title: TestService
 * @Description: TODO
 * @Date: 2023/7/14 15:47
 */
@Service
public class TestService {

    @Autowired
    private TestOneMapper testTMapper;

    @Autowired
    private UserService userService;

    @MainTransaction(1)
    @Transactional(rollbackFor = Exception.class)
    public void testOne(){
        userService.useTest(Thread.currentThread());
        TestOne testOne = new TestOne();
        testOne.setName("test999");
        testOne.setId(1);
        testTMapper.insert(testOne);
        //int a=10/0;
    }

}
